package com.woniu.humanresource.service.impl;


import com.woniu.humanresource.dao.ContractDao;
import com.woniu.humanresource.entity.Contract;
import com.woniu.humanresource.entity.PageBean;
import com.woniu.humanresource.service.ContractService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class ContractServiceImpl implements ContractService {
    @Resource
    ContractDao contractDao;

    @Override
    public void insertContract(Contract contract) {
        contractDao.insertContract(contract);
    }


    @Override
    public PageBean<Contract> selectCondition(Contract contract, int pageIndex, int pageSize) {
        //        查询合同信息列表
        List<Contract> contracts = contractDao.selectCondition(contract, pageIndex, pageSize);
        //        封装为PageBean对象，并设置属性
        PageBean<Contract> pageBean=new PageBean<>();
        pageBean.setBeanList(contracts);
        pageBean.setPageSize(pageSize);
        pageBean.setPageIndex(pageIndex);
        pageBean.setBeginEnd();
        pageBean.setTotalRecord(selectConditionCount(contract));
        return pageBean;
    }

    @Override
    public int selectConditionCount(Contract contract) {
        int count = contractDao.selectConditionCount(contract);

        return count;
    }

    @Override
    public void deleteContract(int id) {
        contractDao.deleteContract(id);
    }

    @Override
    public void updateContract(Contract contract) {
        contractDao.updateContract(contract);
    }
}
